Micron Document
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
| SparkN0de-git | SparkN0de |
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Commit 237d56059d4cfb4f72cf338af2166d7d3a7ac170


Parents : efd6285
Author : Mark Qvist <mark@unsigned.io>
Date : 2025-12-30T12:16:24+01:00

Markup handling improvements

Changes

2 files changed, 13 insertions(+), 3 deletions(-)


Diff

diff --git a/nomadnet/ui/textui/Browser.py b/nomadnet/ui/textui/Browser.py
index b0885b7..391f893 100644
--- a/nomadnet/ui/textui/Browser.py
+++ b/nomadnet/ui/textui/Browser.py
@@ -1040,7 +1040,8 @@ class Browser:
fg = self.markup[fgpos+5:endpos]
self.page_foreground_color = fg
- self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
+ try: self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
+ except Exception as e: self.attr_maps = [urwid.AttrMap(urwid.Text(f"Could not render page: {e}"), "inactive_text")]
self.response_progress = 0
self.response_speed = None
@@ -1107,7 +1108,8 @@ class Browser:
fg = self.markup[fgpos+5:endpos]
self.page_foreground_color = fg
- self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
+ try: self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
+ except Exception as e: self.attr_maps = [urwid.AttrMap(urwid.Text(f"Could not render page: {e}"), "inactive_text")]
self.response_progress = 0
self.response_speed = None
@@ -1259,7 +1261,9 @@ class Browser:
fg = self.markup[fgpos+5:endpos]
self.page_foreground_color = fg
- self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
+ try: self.attr_maps = markup_to_attrmaps(strip_modifiers(self.markup), url_delegate=self, fg_color=self.page_foreground_color, bg_color=self.page_background_color)
+ except Exception as e: self.attr_maps = [urwid.AttrMap(urwid.Text(f"Could not render page: {e}"), "inactive_text")]
+
self.response_progress = 0
self.response_speed = None
self.progress_updated_at = None

diff --git a/nomadnet/ui/textui/MicronParser.py b/nomadnet/ui/textui/MicronParser.py
index 0599216..d8adbb4 100644
--- a/nomadnet/ui/textui/MicronParser.py
+++ b/nomadnet/ui/textui/MicronParser.py
@@ -146,6 +146,12 @@ def parse_line(line, state, url_delegate):
# Only parse content if not in literal state
if not state["literal"]:
+ # Apply markup sanitization
+ if first_char == ">" and "`<" in line:
+ # Remove heading status from lines containing fields
+ line = line.lstrip(">")
+ first_char = line[0]
+
# Check if the command is an escape
if first_char == "\\":
line = line[1:]


──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────